package com.tesis.constdroid;

import java.util.Vector;

import android.content.Context;
import android.widget.Toast;
import choco.Choco;
import choco.kernel.model.constraints.Constraint;
import choco.kernel.model.variables.integer.IntegerExpressionVariable;
import choco.kernel.model.variables.integer.IntegerVariable;

public class Constraints {
	
	private Vector<Constraint> constraints; 
	private Vector<String> contraintsText;
	private boolean showMsg=true;
	
	

	
	public Constraints() {
		constraints = new Vector<Constraint>();
		contraintsText = new Vector<String>();
	}
	
	
	
	public void add_VEVM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		String text="";
		IntegerExpressionVariable ie2 = null;
		String text1 =var2.get(0).getName();
		for(int i=1;i<var2.size();i++){
			text1 = text1 + "," + var2.get(i).getName();
		}
		if(var2.size()<2){
			ie2=var2.get(0);
		}
		else{
			ie2=Choco.mult(var2.get(0), var2.get(1));
			for(int i =1; i<var2.size()-1;i++){
				ie2=Choco.mult(ie2, Choco.mult(var2.get(i), var2.get(i+1))) ;
			}
		}
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i),ie2, op);
			text = text + var1.get(i).getName()  + " " + op + " "  + text1 + "\n";
			contraintsText.add("VM: " +  var1.get(i).getName()  + " " + op + " "  + text1 + "\n");
		}
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_VC_Constraint(IntegerVariable var1,int var2,String op,Context t){
		
		String text=var1.getName();
		addConstraint(var1, var2, op);
		text = text + " "+ op + " " + var2;
		contraintsText.add("VC: " + text + "\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}

	public void add_AEVM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		
		IntegerExpressionVariable ie2 = getMultIntegerExprecion(var2);
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), ie2, op);
		}
		
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("AEVM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	
	public void add_AEAM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		IntegerExpressionVariable ie2 = getMultIntegerExprecion(var2);
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), ie2, op);
		}
		
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		contraintsText.add("AEAM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_AEAS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		IntegerExpressionVariable ie2 = Choco.sum(v2);
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), ie2, op);
		}
		
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		contraintsText.add("AEAS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_AEVS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		
		IntegerExpressionVariable ie2 = Choco.sum(v2);
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), ie2, op);
		}
		
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("AEVS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}

	public void add_AEC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
	
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), var2, op);
		}
		
		text = text + " " + op + " "+ var2; 	
		contraintsText.add("AEC: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_ASVS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		
		addConstraint(Choco.sum(v1), Choco.sum(v2), op);
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("ASVS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_ASAS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		
		IntegerExpressionVariable ie1=Choco.sum(v1);
		IntegerExpressionVariable ie2=Choco.sum(v2);
		
		addConstraint(ie1, ie2, op);
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		
		contraintsText.add("ASAS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_ASAM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerExpressionVariable ie1=Choco.sum(v1);
		IntegerExpressionVariable ie2=getMultIntegerExprecion(var2);
		addConstraint(ie1, ie2, op);
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		contraintsText.add("ASAM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_AMAM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerExpressionVariable ie1=getMultIntegerExprecion(var1);
		IntegerExpressionVariable ie2=getMultIntegerExprecion(var2);
		addConstraint(ie1, ie2, op);
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		contraintsText.add("AMAM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	public void add_AMAS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerExpressionVariable ie1=getMultIntegerExprecion(var1);
		IntegerExpressionVariable ie2= Choco.sum(v2);
		addConstraint(ie1, ie2, op);
		text = text + " " + op + " "; 	
		text = text + var2.get(0).getName().substring(0, var2.get(0).getName().length()-3);
		contraintsText.add("AMAS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_AMVS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);

		IntegerExpressionVariable ie1 = getMultIntegerExprecion(var1) ;
		IntegerExpressionVariable ie2 = Choco.sum(v2);
		
		addConstraint(ie1, ie2, op);
		
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("AMVS: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	
	public void add_ASVM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerVariable []v2 = getIntegerVariablesArray(var2);

		IntegerExpressionVariable ie1 = Choco.sum(v1);
		IntegerExpressionVariable ie2 = getMultIntegerExprecion(var2);
		
		addConstraint(ie1, ie2, op);
		
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("ASVM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_AMVM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		
		IntegerVariable []v2 = getIntegerVariablesArray(var2);

		IntegerExpressionVariable ie1 = getMultIntegerExprecion(var1);
		IntegerExpressionVariable ie2 = getMultIntegerExprecion(var2);
		
		addConstraint(ie1, ie2, op);
		
		text = text + " " + op + " "; 	
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
				text = text + "," + v2[i].getName();
		}
		contraintsText.add("AMVM: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	
	
	public void add_AMC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerExpressionVariable ie1 = getMultIntegerExprecion(var1);
		addConstraint(ie1, var2, op);
		text = text + " " + op + " "+ var2; 	
		contraintsText.add("AMC: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_ASC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
		
		String text = var1.get(0).getName().substring(0, var1.get(0).getName().length()-3);
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerExpressionVariable ie1 = Choco.sum(v1);
		addConstraint(ie1, var2, op);
		text = text + " " + op + " "+ var2; 	
		contraintsText.add("ASC: " + text +"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	
	public void add_VEC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
		String text = "";
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i), var2, op);
			text = text + var1.get(i).getName() + " " + op + " "  + var2 + "\n";
			contraintsText.add("VC: " + var1.get(i).getName() + " " + op + " "  + var2 +"\n");
		}
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_VSVE_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = "";
		String text1 = var1.get(0).getName();
		IntegerVariable[] v1 = getIntegerVariablesArray(var1);
		
		for(int i=1;i<var1.size();i++){
			text1 = text1 + "," + var1.get(i).getName();
		}
		
		for(int i=0;i<var2.size();i++){
			addConstraint(Choco.sum(v1), var2.get(i), op);
			text = text + text1 + " " + op + " "  + var2.get(i).getName() + "\n";
			contraintsText.add("SV: " + text1 + " " + op + " " + var2.get(i).getName() + "\n");
		}
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}

	public void add_VEVS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
	
		String text = "";
		String text1 = var2.get(0).getName();
	
		for(int i=1;i<var2.size();i++){
			text1 = text1 + "," + var2.get(i).getName();
		}
		
		IntegerVariable[] v2 = getIntegerVariablesArray(var2);
		
		for(int i=0;i<var1.size();i++){
			addConstraint(var1.get(i),Choco.sum(v2), op);
			text = text  + var1.get(i).getName() + " " + op + " " + text1 + "\n";
			contraintsText.add("VS: " + var1.get(i).getName()  + " " + op + " " + text1 + "\n");
		}
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
}

	public void add_VSV_Constraint(Vector<IntegerVariable> v1,IntegerVariable var2,String op,Context t){
		
		Vector<IntegerVariable> v2 = new Vector<IntegerVariable>();
		v2.add(var2);
		add_VSVS_Constraint(v1,v2,op, t);
		
	}
	
	public void add_VSVS_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		String text = "";
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		
		text = text + v1[0].getName();
		
		for(int i=1;i<var1.size();i++){
			text = text + "," + v1[i].getName();
		}
		
		addConstraint(Choco.sum(v1), Choco.sum(v2), op);
		text = text + " " + op + " ";
		
		text = text + v2[0].getName();
		for(int i=1;i<var2.size();i++){
			text = text + "," + v2[i].getName();
		}
		
		contraintsText.add("SS: "+text+"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
		
	}
	
	public void add_VMVS_Constraint(Vector<IntegerVariable> v1,Vector<IntegerVariable> v2,String op,Context t){
		
		String text = "";
		
		IntegerVariable []var1 = getIntegerVariablesArray(v1);
		IntegerVariable []var2 = getIntegerVariablesArray(v2);
		
		IntegerExpressionVariable ie1 = null;
		
		text = text + var1[0].getName();
		
		for(int i=1;i<v1.size();i++){
			text = text + "," + var1[i].getName();
		}
		
		if(v1.size()<2){
			ie1=var1[0];
		}
		else{
			ie1=Choco.mult(var1[0], var1[1]);
			for(int i =1; i<v1.size()-1;i++){
				ie1=Choco.mult(ie1, Choco.mult(var1[i], var1[i+1]));
			}
		}
		addConstraint(ie1, Choco.sum(var2), op);
		text = text + " " + op + " ";
		text = text + var2[0].getName();
		for(int i=1;i<v2.size();i++){
			text = text + "," + var2[i].getName();
		}
		contraintsText.add("MS: "+text+"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
	
	public void add_VSVM_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = "";
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		IntegerVariable []v2 = getIntegerVariablesArray(var2);
		IntegerExpressionVariable ie1 = Choco.sum(v1);
		IntegerExpressionVariable ie2 = getMultIntegerExprecion(var2);
		text = text + v1[0].getName();
		
		for(int i=1;i<var1.size();i++){
			text = text + "," + v1[i].getName();
		}
		
		
		text = text + " " + op + " " + v2[0].getName();
		for(int i=1;i<var2.size();i++){
			text = text + "," + v2[i].getName();
		}
		addConstraint(ie1, ie2, op);
		contraintsText.add("SM: "+text+"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
	}
		
	public void add_VSC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
		
		String text = "";
		IntegerVariable []v1 = getIntegerVariablesArray(var1);
		text = text + v1[0].getName();
		for(int i=1;i<var1.size();i++){
			text = text + "," + v1[i].getName();
		}
		addConstraint(Choco.sum(v1), var2, op);
		text = text + " " + op + " "  + var2;
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
		contraintsText.add("SC: "+text+"\n");
		
	}
	
	public void add_VMC_Constraint(Vector<IntegerVariable> var1,int var2,String op,Context t){
		
		String text = "";
		
		text = text + var1.get(0).getName();
		for(int i=1;i<var1.size();i++){
			text = text + "," + var1.get(0).getName();
		}
		addConstraint(getMultIntegerExprecion(var1), var2, op);
		text = text + " " + op + " "  + var2;
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
		contraintsText.add("MC: "+text+"\n");
		
	}
	
	private void addConstraint(IntegerExpressionVariable ie1,IntegerExpressionVariable ie2,String op){
		
		if(op.equals("==")){
			Constraint c = Choco.eq(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals(">")){
			Constraint c = Choco.gt(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<")){
			Constraint c = Choco.lt(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals(">=")){
			Constraint c = Choco.geq(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<=")){
			Constraint c = Choco.leq(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<>")){
			Constraint c = Choco.neq(ie1,ie2);
			constraints.add(c);
		}
	}
	
	public void add_VMVM_Constraint(Vector<IntegerVariable> v1,Vector<IntegerVariable> v2,String op,Context t){
		
		String text = "";
		IntegerVariable []var1 = getIntegerVariablesArray(v1);
		IntegerVariable []var2 = getIntegerVariablesArray(v2);
		IntegerExpressionVariable ie1 = null;
		IntegerExpressionVariable ie2 = null;
		
		text = text + var1[0].getName();
		for(int i=1;i<v1.size();i++){
			text = text + "," + var1[i].getName();
		}
		
		if(v1.size()<2){
			ie1=var1[0];
		}
		else{
			ie1=Choco.mult(var1[0], var1[1]);
			for(int i =1; i<v1.size()-1;i++){
				ie1=Choco.mult(ie1, Choco.mult(var1[i], var1[i+1])) ;
			}
		}
		if(v2.size()<2){
			ie2=var2[0];
		}
		else{
			ie2=Choco.mult(var2[0], var2[1]);
			for(int i =1; i<v1.size()-1;i++){
				ie2=Choco.mult(ie2, Choco.mult(var2[i], var2[i+1])) ;
			}
		}
		addConstraint(ie1, ie2, op);
		text = text + " " + op +" " + var2[0].getName();
		for(int i=1;i<v1.size();i++){
			text = text + "," + var2[i].getName();
		}
		contraintsText.add("MM: " + text+"\n");
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
		
	}
	
	public void differents(Vector<IntegerVariable> vars,Context t){
		
		String text="Differents: ";
		text= text  + vars.get(0).getName();
		for (int i = 1;i<vars.size();i++){
			text= text + ","  + vars.get(i).getName();			
		}
		
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();;
		Constraint c = Choco.allDifferent(getIntegerVariablesArray(vars));
		constraints.add(c);
		contraintsText.add(text+"\n");
	}

	public void allDifferents(Vector<IntegerVariable> vars,Context t){
		String text="All_Differents";
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();;
		Constraint c = Choco.allDifferent(getIntegerVariablesArray(vars));
		constraints.add(c);
		contraintsText.add("All_Differents\n");
	}
	
	public void add_VMVE_Constraint(Vector<IntegerVariable> var1,Vector<IntegerVariable> var2,String op,Context t){
		
		String text = "";
		
		IntegerExpressionVariable ie1 = null;
		String text1 = var1.get(0).getName();
		for(int i=1;i<var1.size();i++){
			text = text + "," + var1.get(i).getName();
		}
		
		ie1 = getMultIntegerExprecion(var1);
		for(int i=0;i<var2.size();i++){
			addConstraint(ie1, var2.get(i), op);
			text = text + text1 + " " + op + " "  + var2.get(i).getName() + "\n";
			contraintsText.add("MV: " + text1 + " " + op + " " + var2.get(i).getName() + "\n");
		}
		
		if(showMsg)Toast.makeText(t, text, Toast.LENGTH_LONG).show();
		
	}
	
	public Vector<Constraint> getConts() {
		return constraints;
	}

	public Vector<String> getContraintsText() {
		
		return contraintsText;
	}
	
	private void addConstraint(IntegerExpressionVariable ie1,int ie2,String op){
		
		if(op.equals("==")){
				Constraint c = Choco.eq(ie1,ie2);
				constraints.add(c);
		}
		if(op.equals(">")){
			Constraint c = Choco.gt(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<")){
			Constraint c = Choco.lt(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals(">=")){
			Constraint c = Choco.geq(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<=")){
			Constraint c = Choco.leq(ie1,ie2);
			constraints.add(c);
		}
		if(op.equals("<>")){
			Constraint c = Choco.neq(ie1,ie2);
			constraints.add(c);
		}
	}
	
	public void addConstraint(Constraint c){
		constraints.add(c);
	}
	public void addConstraintText(String c){
		contraintsText.add(c);
	}
	
	private IntegerExpressionVariable getMultIntegerExprecion(Vector<IntegerVariable> var){
		
		IntegerExpressionVariable ie = null;
		
		if(var.size()<2){
			ie=var.get(0);
		}
		else{
			ie=Choco.mult(var.get(0), var.get(1));
			for(int i =1; i<var.size()-1;i++){
				ie=Choco.mult(ie, Choco.mult(var.get(i), var.get(i+1))) ;
			}
		}
		return ie;
	}

	private IntegerVariable[] getIntegerVariablesArray(Vector<IntegerVariable> vars){
		
		IntegerVariable var[];
		
		var = new IntegerVariable[vars.size()];
		
		for (int i = 0;i<vars.size();i++){
			var[i]=vars.get(i);			
		}
		return var;
	}


	public void setShowMsg(boolean showMsg) {
		this.showMsg = showMsg;
	}
	
	
}
